public class Singletontest02 {
    static {
        System.out.println("该设计模式为饿汉式-静态代码块实现! ");
    }

    public static void main(String[] args) throws Exception {
        Singletion02 instance =  Singletion02.getInstance();
        Singletion02 instance2 = Singletion02.getInstance();
        System.out.println(instance == instance2);
        System.out.println(instance.hashCode());
        System.out.println(instance2.hashCode());
    }
}
class Singletion02{
    private Singletion02(){

    }
    static {
        instance=new Singletion02();
    }
    private static Singletion02 instance;
    public static Singletion02 getInstance(){
        return instance;
    }
}

